#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;

int removeElement(int* nums, int numsSize, int val) 
{
    int src = 0, des = 0;
    while (src < numsSize)
    {
        if (nums[src] == val)
            src++;
        else
            nums[des++] = nums[src++];
    }
    return des;
}

int removeDuplicates(int* nums, int numsSize) {
    int src = 1, dest = 0;
    while (src < numsSize)
    {
        if (nums[src] == nums[dest])
            src++;
        else
            nums[++dest] = nums[src++];
    }
    return dest + 1;
}

void merge(int* nums1, int nums1Size, int m, int* nums2, int nums2Size, int n) {
    int src1 = m - 1, src2 = n - 1, dest = m + n - 1;
    while (src1 >= 0 && src2 >= 0)
    {
        if (nums1[src1] > nums2[src2])
            nums1[dest--] = nums1[src1--];
        else
            nums1[dest--] = nums2[src2--];
    }
    while (src2 >= 0)
        nums1[dest--] = nums2[src2--];
}

